% %Name:		Xu Zelin 许泽林
% %Course:	Digital Content Security
% %Project：  F5(attack)
% clear;
% clc;
% 不做任何更改，查看操作前后有多大的变化
path_list=dir('./image/*.jpg');
img_num = length(path_list);%获取图像总数量
for j = 1:img_num
    image_name = path_list(j).name;% 发送图像名
    send_image =  imread(strcat('./image/',image_name));
    receive_image = imread(strcat('./receive/Imbeded',image_name));
    fprintf('%d %s\n',j,image_name);% 显示正在处理的图像名
    num(j)=j;
    peak_snr(j) = psnr(receive_image,send_image);
end
subplot(2,2,1)
plot(num,peak_snr)
title('加密解密前后图像的变化程度');
xlabel('name','FontSize',14);
ylabel('psnr/dB','FontSize',14);
%只针对一幅图像，嵌入秘密信息比特数和psnr对应的关系
path_list=dir('./mount-psnr/*.jpg');
img_num = length(path_list);%获取图像总数量
bits=[3,4,5,6,7,8,9];
orgin=imread('./image/5.1.12.jpg');
for j = 1:img_num
    image_name = path_list(j).name;% 发送图像名
    send_image =  imread(strcat('./mount-psnr/',image_name));
    fprintf('%d %s\n',j,image_name);% 显示正在处理的图像名
    p_snr(j) = psnr(send_image,orgin);
end
subplot(2,2,2)
plot(bits,p_snr)
title('嵌入的比特位数与图像变化的关系');
xlabel('hidden bits','FontSize',14);
ylabel('psnr/dB','FontSize',14);

% %经过f5处理前后的dct系数直方图对比
before=imread('5.1.12.jpg');
after=imread('./receive/Imbeded5.1.12.jpg');
before1 = dct2(before);
after1 = dct2(after);
before_ = before1;
after_ = after1;
before1(abs(before1) < 5) = 0; 
after1(abs(after1) < 5) = 0; 
before_dct = before_ - before1;
after_dct = after_ - after1;
before_HIGH = int8(idct2(before_dct));
after_HIGH = int8(idct2(after_dct));
subplot(2,2,3)
histogram(before_HIGH,30)
hold on
histogram(after_HIGH,30)
title('经过f5处理前后的dct系数直方图对比','fontsize',16);
xlabel('dct系数');ylabel('出现次数');
legend('before','after');

